//   Copyright 2012,2013 Vaughn Vernon
//
//   Licensed under the Apache License, Version 2.0 (the "License");
//   you may not use this file except in compliance with the License.
//   You may obtain a copy of the License at
//
//       http://www.apache.org/licenses/LICENSE-2.0
//
//   Unless required by applicable law or agreed to in writing, software
//   distributed under the License is distributed on an "AS IS" BASIS,
//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//   See the License for the specific language governing permissions and
//   limitations under the License.

package com.saasovation.common.event.sourcing;

import java.util.List;

import com.saasovation.common.domain.model.DomainEvent;

/**
 * 事件存储
 */
public interface EventStore {

    /**
     * 附加
     * @param aStartingIdentity     事件流ID
     * @param anEvents              领域事件清单
     */
    public void appendWith(EventStreamId aStartingIdentity, List<DomainEvent> anEvents);

    /**
     * 关闭
     */
    public void close();

    /**
     * 获取（最后接收到的事件）以来的事件
     * @param aLastReceivedEvent 最后接收到的事件
     * @return 返回列表
     */
    public List<DispatchableDomainEvent> eventsSince(long aLastReceivedEvent);

    /**
     * 获取（身份识别ID）以来的事件流
     * @param anIdentity 事件流ID
     * @return  返回事件流
     */
    public EventStream eventStreamSince(EventStreamId anIdentity);

    /**
     * 获取完整的事件流
     * @param anIdentity  事件流ID
     * @return  返回事件流
     */
    public EventStream fullEventStreamFor(EventStreamId anIdentity);

    /**
     * 清除
     */
    public void purge(); // mainly used for testing主要用于测试

    /**
     * 注册事件通知
     * @param anEventNotifiable 事件可通知
     */
    public void registerEventNotifiable(EventNotifiable anEventNotifiable);
}
